package leetcode.weekly.week329;

import java.util.ArrayList;
import java.util.List;

//Solution1Test
public class Solution1 {

	public int alternateDigitSum(int n) {
		int ans = 0;
		List<Integer> list = new ArrayList<>();
		while (n > 0) {
			list.add(n % 10);
			n /= 10;
		}
		for (int i = list.size() - 1, mul = 1; i >= 0; i--, mul *= -1) {
			ans += list.get(i) * mul;
		}
		return ans;
	}

}
